COVERAGE=ncov cov
MODE=short long

# creating sim_modeand sim_coverage in case they are not present
prepare:
	@if ! test -f sim_mode; then echo "setenv  SIM_MODE \"short\"" > sim_mode; fi
	@if ! test -f sim_coverage; then echo "setenv  SIM_COVERAGE \"cov_dis\"" > sim_coverage; fi

# This target invokes modelsim through the simulation engine in batch mode
sim_batch: prepare
	eval vsim -c -do tcl/tb.tcl

# This target invokes modelsim through the simulation engine in gui mode
sim_gui: prepare
	eval vsim -gui -do tcl/tb.tcl

# creating sim_mode
$(MODE):
	@if [ "$(@)" = "long" ]; then echo "setenv  SIM_MODE \"long\"" > sim_mode; else echo "setenv  SIM_MODE \"short\"" > sim_mode; fi

# creating sim_coverage
$(COVERAGE):
	@if [ "$(@)" = "cov" ]; then echo "setenv  SIM_COVERAGE \"cov_en\"" > sim_coverage; else echo "setenv  SIM_COVERAGE \"cov_dis\"" > sim_coverage; fi

# Clean old files
clean:
	rm -rf rtl_work verilog_libs modelsim.ini transcript *.txt *.wlf *.opt covhtmlreport *.ucdb sim_coverage sim_mode

